<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./wangEditor.css">
    <script src="./wangEditor.js"></script>
</head>

<body>
    <button id="set">设置内容</button>
    <button id="get">获取内容</button>
    <br><br>
    <div id="div1">
        <p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p>
    </div>

    <script>
        const E = window.wangEditor
        const editor = new E('#div1')
        // 或者 const editor = new E( document.getElementById('div1') )
        editor.create()


        //设置内容
        document.getElementById('set').onclick = function () {
            //editor.txt.html('<p>用 JS 设置的内容</p>') // 重新设置编辑器内容

            editor.txt.append('<p>追加的内容</p>')
        }

        //获取内容
        document.getElementById('get').onclick = function(){
            //console.log(editor.txt.html());  //获取 html

            console.log(editor.txt.text());  //获取 text 文本。
        }
    </script>
</body>

</html>